<?php

require '../../base.php';
require '../../msg/MessageStatic.class.php';
if (!defined('DP_BASE_DIR')){
	die(MessageStatic::$notAccessMessage);
}

require DP_BASE_DIR .'/integration/to/FormBaseTO.class.php';
require DP_BASE_DIR .'/integration/vo/WorkInfoVO.class.php';
require DP_BASE_DIR .'/integration/vo/LanguageInfoVO.class.php';
require DP_BASE_DIR .'/integration/vo/CompetenceInfoVO.class.php';
require DP_BASE_DIR .'/integration/vo/ProfesionalSkillInfoVO.class.php';



require DP_BASE_DIR .'/bussines/RecruitmentMngr.class.php';



/*
 * start the insert processes into db
 */

// instance the transfer object to bussines send
$objFormBase = new FormBaseTO();

/*
 * set the information to step 1
 */
$objFormBase->intLCID = $_POST['txtIdLC'];
$objFormBase->stPingID = $_POST['txtPingID'];
$objFormBase->stName1 = $_POST['txtName1'];
$objFormBase->stName2 = $_POST['txtName2'];
$objFormBase->stLastName1 = $_POST['txtLastName1'];
$objFormBase->stLastName2 = $_POST['txtLastName2'];
$objFormBase->stEmail = $_POST['txtMail'];
// type of Identification
$objFormBase->intIdTpID = $_POST['cboTpID'];
// Identification
$objFormBase->intID = $_POST['txtID'];
// Birthday
$objFormBase->dateBirthday= $_POST['txtBirthDay'];
// From city
$objFormBase->stFrontCity= $_POST['txtFromCity'];
// addres place
$objFormBase->stAddresPlace= $_POST['txtAddresPlace'];
// phone
$objFormBase->stPhone= $_POST['txtPhone'];
// cell phone
$objFormBase->stCelPhone= $_POST['txtCelPhone'];
/*
 * 
 * set the information to step 2
 * 
 */
// id from list of university in DB
$objFormBase->intIdUniversity= $_POST['cmbUnivesity'];

$objFormBase->stOtherUniversity= $_POST['txtOtherUniversity'];

// id from list of university in DB
$objFormBase->intIdCommonUniversityProgram= $_POST['cmbCarrer'];
// in case of extrange university program
$objFormBase->stOtherUniversityProgram= $_POST['txtOtherCarrer'];
// id of list in semester DB	
$objFormBase->intIdSemester= $_POST['cmbSemester'];
// number of Academic hour for week
$objFormBase->stAcademicHour= $_POST['cmbNumberOfAcademicHours'];
// number of AIESEC hour for week that you can spend
$objFormBase->stAIESECHour = $_POST['cmbNumberOfAIESECHours'];
/*
 * ArrayList whit the list of work information
 * implementation of /base/list/ArrayList.class.php
 * 
 * txtWorkNameCompany1
 * cmdWorkDurationMonth1
 * txtWorkResp1
 * 
 */

$lstWorkInfo = new ArrayList();

for($i = 1; $i <= 3; $i += 1)
if (isset($_POST['txtWorkNameCompany'.$i]) && $_POST['txtWorkNameCompany'.$i] != '' && 
	isset($_POST['cmdWorkDurationMonth'.$i]) && $_POST['cmdWorkDurationMonth'.$i] != '' &&
	isset($_POST['txtWorkResp'.$i]) && $_POST['txtWorkResp'.$i] != ''){
	$workInfoVO = new WorkInfoVO();
	$workInfoVO->stNameCompany = $_POST['txtWorkNameCompany'.$i];
	$workInfoVO->stDurationMonth = $_POST['cmdWorkDurationMonth'.$i];
	$workInfoVO->stResp = $_POST['txtWorkResp'.$i];
	$lstWorkInfo->add($workInfoVO);
}

$objFormBase->lstWorkInformation = $lstWorkInfo;

/*
 * ArrayList whit the list with language information
 * implementation of /base/list/ArrayList.class.php
 * 
 * cmbLang1	
 * cmbLangReading1
 * cmbLangWriting1
 * cmbLangComprehension1
 */


$lstLanguageInfo = new ArrayList();

for($i = 1; $i <= 3; $i += 1)
if (isset($_POST['cmbLang'.$i]) && $_POST['cmbLang'.$i] != '' && 
	isset($_POST['cmbLangReading'.$i]) && $_POST['cmbLangReading'.$i] != '' &&
	isset($_POST['cmbLangWriting'.$i]) && $_POST['cmbLangWriting'.$i] != '' &&
	isset($_POST['cmbLangComprehension'.$i]) && $_POST['cmbLangComprehension'.$i] != ''){
	$languageInfoVO = new LanguageInfoVO();
	$languageInfoVO->intIdTpLang = $_POST['cmbLang'.$i];
	$languageInfoVO->intIdTpReading = $_POST['cmbLangReading'.$i];
	$languageInfoVO->intIdTpWriting = $_POST['cmbLangWriting'.$i];
	$languageInfoVO->intIdTpComprehension = $_POST['cmbLangComprehension'.$i];
	$lstLanguageInfo->add($languageInfoVO);
}

$objFormBase->lstlanguageInformation= $lstLanguageInfo;


/*
 * 
 * set the information to step 3
 * 
 */	


/*
 * ArrayList whit the list of skilss that would like to develop
 * implementation of /base/list/ArrayList.class.php
 * 
 * for that find all skills and compare with the post info
 */

$lstProfesionalSkills = RecruitmentMngr::getProfesionalSkills();
$lstProfesionalSkillsSelected = new ArrayList();
$lovTO = new LovTO();
// foreach LovTO into $lstOptions add option value in cbo
while($lstProfesionalSkills->hasNext()){
	$lovTO = $lstProfesionalSkills->next();
	if(isset($_POST[$lovTO->name])){
		$profesionalSkillInfoVO = new ProfesionalSkillInfoVO();
		$profesionalSkillInfoVO->intIdPSkill = $_POST[$lovTO->name];
		$lstProfesionalSkillsSelected->add($profesionalSkillInfoVO); 
	}
}

$objFormBase->lstSkillsToLikeDevelop= $lstProfesionalSkillsSelected;
/*
 * ArrayList whit the list with 3 strong competences
 * implementation of /base/list/ArrayList.class.php
 * 
 * prefix is chkStrongComp
 */

$lstComp = RecruitmentMngr::getAIESECCompetencesForChkBox('chkStrongComp');
$lstStrongCompSelected = new ArrayList();
$lovTO = new LovTO();
// foreach LovTO into $lstOptions add option value in cbo
while($lstComp->hasNext()){
	$lovTO = $lstComp->next();
	if(isset($_POST[$lovTO->name])){
		$competenceInfoVO = new CompetenceInfoVO();
		$competenceInfoVO->intIdCompetence = $_POST[$lovTO->name];
		$lstStrongCompSelected->add($competenceInfoVO); 
	}
}
$objFormBase->lstStrongCompetentes= $lstStrongCompSelected;
/*
 * ArrayList whit the list with 3 weak competences
 * implementation of /base/list/ArrayList.class.php
 * 
 * prefix is chkWeakComp
 */
$lstComp = RecruitmentMngr::getAIESECCompetencesForChkBox('chkWeakComp');
$lstWeakCompSelected = new ArrayList();
$lovTO = new LovTO();
// foreach LovTO into $lstOptions add option value in cbo
while($lstComp->hasNext()){
	$lovTO = $lstComp->next();
	if(isset($_POST[$lovTO->name])){
		$competenceInfoVO = new CompetenceInfoVO();
		$competenceInfoVO->intIdCompetence = $_POST[$lovTO->name];
		$lstWeakCompSelected->add($competenceInfoVO); 
	}
}
$objFormBase->lstWeakCompetentes= $lstWeakCompSelected;

/*
 * 
 * set the information to step 4
 * 
 */	
//question if you interes in live international exp
$objFormBase->stInteresInLiveXExp= $_POST['cmbInterestedXP'];

//if $booleanInteresInLiveXExp is true then this value can't be null
$objFormBase->stSemesterThatCouldBeLiveThisExp= $_POST['cmbSemesterToTakeX'];
// id in DB of list available duration
$objFormBase->stDurationOfXExp= $_POST['cboDurationOfX'];
/*
 * ArrayList list of medio to know of AIESEC.
 * implementation of /base/list/ArrayList.class.php
 * 
 * prefix chkMediaToKnowAIESEC
 */ 

$lstMedia = RecruitmentMngr::getMediaToKnowAIESEC('chkMediaToKnowAIESEC');
$lstMediaSelected = new ArrayList();
$lovTO = new LovTO();
// foreach LovTO into $lstOptions add option value in cbo
while($lstMedia->hasNext()){
	$lovTO = $lstMedia->next();
	if(isset($_POST[$lovTO->name])){
		$mediaToKnowAIESECInfoVO = new MediaToKnowAIESECInfoVO();
		$mediaToKnowAIESECInfoVO->stNameMedia = $_POST[$lovTO->name];
		$lstMediaSelected->add($mediaToKnowAIESECInfoVO); 
	}
}

$objFormBase->lstMediaToKnowAIESEC = $lstMediaSelected;

$objFormBase->stOtherMediaToKnowAIESEC = $_POST['txtOTHERMediaToKnowAIESEC']; 

$objFormBase->stWhyDidYouDecideAplyToAIESEC = $_POST['txtWhyDecideAply'];

$objFormBase->stWhoDoYouThinkYouCouldContributeAIESEC = $_POST['txtHowDoYouContributeAIESEC'];


/**
 * This code save the form in the 
 */

RecruitmentMngr::saveForm($objFormBase);

?>
